/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package nominalitzacions.ui;

//import java.io.IOException;
//import nominalitzacions.domain.LanguageDomainController;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import nominalitzacions.domain.LanguageDomainController;
import nominalitzacions.domain.PasswordDomainController;
import nominalitzacions.domain.SettingsDomainController;
import nominalitzacions.domain.UrlDomainController;

/**
 *
 * @author daniel.camacho.rodriguez
 */
public class FirstRunViewController {

    private PrincipalViewController PVC;
    
    private PasswordDomainController PDC;
    private FirstRunView FRV;

    private LanguageDomainController LDC;
    private UrlDomainController UDC;

    public FirstRunViewController() throws IOException{
        
        UDC = new UrlDomainController();
        //if(!UDC.isFirst()) UDC.createFolders();
        FRV = new FirstRunView(this);    
        LDC = new LanguageDomainController();
        PDC = new PasswordDomainController();
    }

    public void setVisible() throws FileNotFoundException, IOException{
        if(!UDC.isFirst()) UDC.createFolders();
        FRV.setVisible(true);
    }

    public void passIs(String pass) throws IOException {
        PDC.changePassTo(pass);
    }

    public void previous(int vista){
        FRV.changeTo(vista - 1);
    }

    public void next(int vista) throws FileNotFoundException, IOException{
        if(!(new File(UDC.getRoot()).exists())) UDC.createFolders();
        FRV.changeTo(vista + 1);
    }
    
    public void closeFirstRun(){
        FRV.setInvisible();
    }

    public void setLanguage(String lang, String inf, String irr, String noun, String corp) throws IOException {
        // Falta implementar
        System.out.println(lang);
        System.out.println(inf);
        System.out.println(irr);
        System.out.println(noun);
        System.out.println(corp);

        LDC.importLanguage(inf, irr, noun, corp);
    }

    public boolean isFirst(){
        return UDC.isFirst();
    }

    public void showPrincipalView() throws IOException{
        PVC = new PrincipalViewController();
        PVC.setVisible();
    }

}
